<?php
/**
 * Created by PhpStorm.
 * User: ysfl
 * Date: 16-2-9
 * Time: 上午2:30
 */

namespace modules\admin;

use Cross\MVC\Module;

class FinanceModule extends Module
{
    function Finance_Day_Query()
    {
        /*$Q = $this->Day_Query();
        foreach($f as $v){
            $s = array(
                'time' => $i,
                'price' => $v['price']
            );
            #print_r($s);
        }

        return $s;*/
    }

    function Day_Query($addr,$time)
    {
            $f = $this->link->select(' sum(price) as price')
                ->from('xrk_wastebook')
                ->where(
                    array(
                        'addr' => $addr,
                        'time' => array('like', $time . '%'),
                        'start' => '1'
                    )
                )
                #->getSQL();
                ->stmt()
                ->fetchAll(\PDO::FETCH_ASSOC);


        return $f[0]['price'];
    }

    function Day_Cost($addr,$time)
    {
        $f = $this->link->select(' sum(cost) as price')
            ->from('xrk_wastebook')
            ->where(
                array(
                    'addr' => $addr,
                    'time' => array('like', $time . '%'),
                    'start' => '1'
                )
            )
            #->getSQL();
            ->stmt()
            ->fetchAll(\PDO::FETCH_ASSOC);


        return $f[0]['price'];
    }
}